#include <iostream>
#include <memory>
#include <functional>

class A{
public:

    using callback = std::function<void(int)>;

public:
    A(){
        std::cout << "A()" << std::endl;
    }
    ~A(){
        std::cout << "~A()" << std::endl;
    }

    void set_callback(callback cb){
        std::cout << "set_callback()" << std::endl;
    }
public:
    int value;
};
int main() {
    A a;
    a.set_callback([&a](int i){
        std::cout << "callback()" << std::endl;
        a.value = i;
    });

}